home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12063 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.acns.nwu.edu!aragorn203
  2. From: llong@nwu.edu (Laurie Long)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Beginer C please help me
  5. Date: Thu, 28 Mar 96 18:25:57 GMT
  6. Organization: Northwestern University, Evanston, IL.   USA
  7. Message-ID: <4jeljl$8cg_001@nuts.nwu.edu>
  8. References: <DoLCFx.B7x.0.bloor@torfree.net> <4iq6uc$evq@daryl.scsn.net> <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de>
  9. NNTP-Posting-Host: aragorn203.nuts.nwu.edu
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de>,
  13.    schoof@informatik.uni-wuerzburg.de (Jochen Schoof) wrote:
  14. >Scott Shrader (shrader@scsn.net) wrote:
  15. >: In article <DoLCFx.B7x.0.bloor@torfree.net>, bz786@torfree.net says...
  16. >: >
  17. >: >This may be a stupid mistake but "please help" me.
  18. >: >Thank you very much.
  19. >: >
  20. >: >#include <stdio.h>
  21. >: >#include <math.h>
  22. >: >main ()
  23. >: >{
  24. >: >float n;
  25. >: >n=(9/5);
  26. >: >printf ("n=   %1.3f\n", n);
  27. >: >}
  28. >: >I have complied and run the programme & I got the answer n=1.000
  29. >: >but Iam supposed to get answer 1.8.
  30. >: >Why I got this answer?
  31. >: >-- 
  32. >:What you are asking the program to do is convert an int value (9/5 = 1) to a 
  33.  float.  You need to type cast either the dividend or the divisor as a float.
  34.  
  35.  
  36. Laurie Long
  37. Northwestern University, Evanston, IL.   USA
  38. llong@nwu.edu
  39.